package task

import (
	"fmt"
	"github.com/robfig/cron/v3"
	"math/rand"
	"wf-deploy-agent/cluster"
)

func Start() {
	c := cron.New()

	num := rand.Intn(15) + 5

	//按照随机周期运行补偿job同步插件
	_, _ = c.AddFunc(fmt.Sprintf("@every %dm", num), func() {
		cluster.SyncPlugin()
	})

	//每隔30秒上报心跳
	_, _ = c.AddFunc(fmt.Sprintf("@every %ds", 30), func() {
		cluster.Heartbeat()
	})

	c.Start()
}
